import { pickBy } from '@/utils'
import AttrNavItem from './attr-imagepanel'

export default {
  name: 'WgtJnGridCarousel',
  setting: [
    { label: '标题', key: 'title', component: 'input', value: '爆品直邮' },
    { label: '副标题', key: 'subtitle', component: 'input', value: '宅家买遍全法' },
    {
      label: '总页数',
      key: 'pageNum',
      component: 'number',
      value: 1,
      min: 1,
      max: 9,
      step: 1
    },
    {
      label: '指示器样式',
      key: 'dot',
      component: 'radio',
      options: [
        { name: '点', label: true },
        { name: '滑块', label: false }
      ],
      value: false
    },
    {
      label: '导航项',
      key: 'data',
      component: function (h, { key }) {
        return <AttrNavItem v-model={this.value}/>
      },
      value: [
      ]
    }
  ],
  transformIn: (v) => {
    const { name, base, config, data } = v
    return {
      name,
      ...base,
      ...config,
      data
    }
  },
  transformOut: (v) => {
    return pickBy(v, {
      name: 'name',
      base: (v) => {
        return pickBy(v, {
          title: 'title',
          subtitle: 'subtitle',
          padded: 'padded',
          pageNum: 'pageNum',
          dot: 'dot'
        })
      },
      data: 'data'
    })
  }
}
